/**
 * Created by zzw on 2016/5/18.
 * 佣金主页
 */


$(function(){
    showGrid();
});


//佣金表格数据填充
function  showGrid(){
    var param = JSON.stringify({"token": localStorage.token});
    $.fn.serviceInvoke(serviceAddress.Address, 'agent_app_YongMoney','YongMoneyList.action', param, function (result) {
        if(result.msg=="success"){
            if(result.entity==""||result.entity==null){
                $(".countMoney").html("暂无收益");
            }else{
                $(".countMoney").html(result.entity.countMoney+"元");
            }
            if(result.entity==""||result.entity==null){
                $(".totalMoney").html("0.00");
            }else{
                $(".totalMoney").html(result.entity.totalMoney);
            }
            var tableList = "";
            for(var i=0;i<result.list.length;i++){
                tableList+='<div><input id="label-'+i+'" type="radio"/> <label for="label-'+i+'" class="margin">'+result.list[i].time+'月(￥'+result.list[i].totalMoney+')</label><div class="content"> <table class="table">'
                for(var j=0;j<result.list[i].data.length;j++){
                    tableList+=' <tr><td class="date"> <span class="date-zt">'+result.list[i].data[j].date+'</span> <span class="date-zt">'+result.list[i].data[j].time+'</span> </td> <td><span class="nav-zt">'+result.list[i].data[j].userName+'</span></td> <td>'
                            if(result.list[i].data[j].pay.indexOf("+")==0){
                                tableList+= '<span class="green nav-zt">' +result.list[i].data[j].pay+'</span>';
                            }else{
                                tableList+= '<span class="red nav-zt">' +result.list[i].data[j].pay+'</span>';
                            }
                    tableList+='</td> </tr>';
                }
                tableList+=" </table></div></div>"
            }
            $(".nav").html(tableList);
        }
    });
}
